<?php if (!defined("_ECRIRE_INC_VERSION")) return;

require_once(_DIR_PLUGIN_ECATALOGUE.'classes/class.ProductModel.php');
//include_once(_DIR_PLUGIN_PDK.'functions/pdk_database.php');
 
function formulaires_ecatalogue_product_charger_dist($id_article) {
	$valeurs = array();
    $p_mdl = new ProductModel();    
    $valeurs = $p_mdl->select_by_id($id_article, true);
    
	return $valeurs;
}


function formulaires_ecatalogue_product_verifier_dist($id_article){
    $erreurs = array();
    
    $p_mdl = new ProductModel();    
    $data = $p_mdl->form_data_from_array($_REQUEST);
    $p_mdl->validate($data, $erreurs, true);
         
	return $erreurs;
}


function formulaires_ecatalogue_product_traiter_dist($id_article) {
    $result = array();
    
    $p_mdl = new ProductModel();
    
    $data = $p_mdl->form_data_from_array($_REQUEST);                
    if ($p_mdl->update_by_id($id_article, $data, true)) {
        $result['message_ok'] = _T('ecatalogue:form_saved');
    } else {
        $result['message_erreur'] = _T('ecatalogue:form_error');
    }
    
    return $result;    
}

?>